﻿@{
    Layout = "~/Views/Shared/_ModalForm.cshtml";
    string defId = ViewBag.DefaultId;
    string url = ViewBag.Url;
}


<div class="wrapper">
    <input id="treeId" type="hidden" value="" />
    <input id="treeName" type="hidden" value="" />
    <div id="selector" class="ztree treeselect"></div>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    if (!id) id = '@defId';
    var url = '@Html.Raw(url)';
    $(function () {
        $('#selector').ysTree({
            id: "selector",
            url: url + '?id=' + id ,
            check: { enable: false },
            expandLevel: 0,
            callback: { onClick: saveChoose }
        });
    });

    function saveChoose(event, treeId, treeNode) {
        $("#treeId").val(treeNode.id);
        $("#treeName").val(treeNode.name);
    }
    function GetChooseId() {
        return $("#treeId").val();
    }

    function GetChooseName() {
        return $("#treeId").val();
    }
</script>